package com.example.wanandroid.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.*;


@Configuration
public class MywebConfig implements WebMvcConfigurer {
    @Autowired
    PassportInterceptor passportInterceptor;

    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {

    }

    @Override
    public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {

    }

    @Override
    public void configureAsyncSupport(AsyncSupportConfigurer configurer) {

    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {

    }

    @Override
    public void addFormatters(FormatterRegistry registry) {

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] path = {
                "/user/register",
                "/user/login",
                "/question/getAllQuestions",
                "/question/getQuestionsByUserId",
                "/question/getQuestionDetails"
        };
        registry.addInterceptor(passportInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(path);
    }

}

